home *** CD-ROM | disk | FTP | other *** search
- Path: news.logicon.com!newsmaster@klee
- From: kkolda@logicon.com (Kenneth D. Kolda)
- Newsgroups: comp.lang.c++
- Subject: Re: creating an ostrstream object screws up the istream object!
- Date: 8 Apr 1996 21:02:08 GMT
- Organization: Logicon Operating Systems
- Message-ID: <4kbusg$6jh@piper.logicon.com>
- References: <DpI5IK.DBG@cdf.toronto.edu>
- NNTP-Posting-Host: 137.51.122.161
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.2
-
- In article <DpI5IK.DBG@cdf.toronto.edu>, a209dowm@cdf.utoronto.ca says...
- >
- >in this function I can read & write to the in_stream with no problem
- >
- >int object_name::func_name (ifstream &in_stream);
- >
-
- Whoops!! I assume you didn't mean to include "write" when you're
- refering to the ifstream.
-
- >but if I declare this variable:
- >
- >ostrstream temp_str_stream(temp_string, 2000); // note this is
- oSTRstream
- >
- >then the ifstream object stops working (ie. all reads from it return
- NULL)
- >
- >any ideas? thanks.
- >
- >Paul.
- >
-
- First, I'll assume that temp_string actually is at least 2000 bytes
- long. Have you checked where in_stream.fail() or in_stream.bad()
- get set -- that may indicate where something's gone wrong.
-
- If you're actually writing to your ostrstream, make sure nothing out
- of bounds, of course.
-
- Also, I'm not sure what you mean by return NULL. Since most ifstream/
- istream methods return either istream& or an int, you may be
- misinterpreting the result. Certainly, simply declaring an ostrstream
- should not interfere with your ifstream if all is well.
-
- Ken Kolda
-
-